const defaultState = {
    loading: false,
    clientOrderCount: [],
    clientLineData: [],
    carrierOrderCount: [],
    carrierLineData: []
};

export default function businessAnalysis(state = defaultState, action) {
    const {type, payload, error} = action;
    if (error === true) {
        return {...state, loading: false};
    }
    switch (type) {

        case 'DASHBOARD.QUERY_CLIENT_ORDER':
            return {...state, clientOrderCount: [...payload]};
        case 'DASHBOARD.QUERY_CLIENT_PRICE':
            return {...state, clientLineData: [...payload]};
        case 'DASHBOARD.QUERY_CARRIER_PRICE':
            return {...state, carrierLineData: [...payload]};
        case 'DASHBOARD.QUERY_CARRIER_ORDER':
            return {...state, carrierOrderCount: [...payload]};
        default:
            return state;
    }
}
